Lidar Point Cloud (Experimental)

RadarSimPy is a radar simulation package built with python. Contact me if you are interested in this module.

RadarSimC is the ray tracing engine built with C++. It is capabile of generating the point cloud of a customized scene. This engine is integrated in RadarSimPy.

This ray tracing engine can be used to effective calculation the RCS of a target. It can also be used generate point cloud in a customized scene.

This notebook is available on my GitHub.

Create a Scene

A scene can be created from multiple .stl models.

In this example, 5 objects will be loaded:

  • ground: a 60 m x 60 m plane used as the ground
  • car_1: an Audi R8 model at (0, 10, 0) m
  • car_2: an Audi R8 model at (-4, 0, 0) m
  • car_3: an Audi R8 model at (4, -5, 0) m
  • car_4: an Audi R8 model at (0, -5, 0) m
In [1]:
import numpy as np

ground = {
    'model': '../models/surface_60x60.stl',
    'location': (0, 0, 0),
    'rotation_axis': (0, 0, 0),
    'rotation_angle': 0,
    'speed': (0, 0, 0)
}

car_1 = {
    'model': '../models/audi_r8.stl',
    'location': (0, 10, 0),
    'rotation_axis': (0, 0, 0),
    'rotation_angle': 0,
    'speed': (0, 0, 0)
}

car_2 = {
    'model': '../models/audi_r8.stl',
    'location': (-4, 0, 0),
    'rotation_axis': (0, 0, 0),
    'rotation_angle': 0,
    'speed': (0, 0, 0)
}

car_3 = {
    'model': '../models/audi_r8.stl',
    'location': (4, -5, 0),
    'rotation_axis': (0, 0, 0),
    'rotation_angle': 0,
    'speed': (0, 0, 0)
}

car_4 = {
    'model': '../models/audi_r8.stl',
    'location': (0, -5, 0),
    'rotation_axis': (0, 0, 0),
    'rotation_angle': 0,
    'speed': (0, 0, 0)
}

targets = [ground, car_1, car_2, car_3, car_4]

Lidar

Now, use dict to define a Lidar. It has 3 properties:

  • position: position of the Lidar
  • phi: horzontal scanning angles in degree
  • theta: vertical scanning angles in degree
In [2]:
lidar = {
    'position': [0, 0, 1.5],
    'phi': np.arange(0, 360, 0.2),
    'theta': np.arange(70, 110, 0.5)
}

To generate the point cloud, we can simply use lidar_scene. It will create an numpy array of the point cloud.

In [3]:
import time
from radarsimpy import lidar_scene

tic = time.time()
points = lidar_scene(lidar, targets)
toc = time.time()
print('Exection time:', toc-tic, 's')
Exection time: 0.5120267868041992 s

Plot the Point Cloud

In [4]:
import plotly.graph_objs as go
from plotly.offline import iplot

ray_dots = go.Scatter3d(x=points['positions'][:, 0], y=points['positions'][:, 1], z=points['positions'][:, 2], mode='markers',
                        marker=dict(
                            size=1,
    color=points['positions'][:, 2],
    colorscale='Rainbow',
    opacity=0.5,
),)


layout = go.Layout(
    height=800,
    template='plotly_dark',
    scene=dict(
        aspectmode='data',
    ),
    margin=dict(l=0, r=0, b=0, t=20)
)

fig = go.Figure(data=[ray_dots], layout=layout)
iplot(fig)